package com.edu.exam.enums;

/**
 * 审核类型枚举
 * 
 * @author S-01 Module Designer
 * @version 2.0
 * @since 2025-11-10
 */
public enum AuditType {
    APPLICATION("application", "申请审核"),
    PLAN("plan", "计划审核"),
    ARRANGEMENT("arrangement", "安排审核"),
    RESULT("result", "结果审核"),
    RESOURCE("resource", "资源审核"),
    INVIGILATOR("invigilator", "监考员审核"),
    VENUE("venue", "考场审核"),
    TIME("time", "时间审核"),
    POLICY("policy", "政策审核"),
    QUALITY("quality", "质量审核"),
    COMPLIANCE("compliance", "合规审核"),
    SECURITY("security", "安全审核"),
    FINANCIAL("financial", "财务审核"),
    ACADEMIC("academic", "学术审核"),
    ADMINISTRATIVE("administrative", "行政审核"),
    TECHNICAL("technical", "技术审核"),
    MANUAL("manual", "手动审核"),
    AUTOMATIC("automatic", "自动审核"),
    INITIAL("initial", "初始审核"),
    FINAL("final", "最终审核"),
    INTERIM("interim", "中期审核");

    private final String code;
    private final String description;

    AuditType(String code, String description) {
        this.code = code;
        this.description = description;
    }

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
    /**
     * 根据代码查找枚举值
     *
     * @param code 枚举代码
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果代码不存在
     */
    public static AuditType fromCode(String code) {
        for (AuditType type : AuditType.values()) {
            if (type.code.equals(code)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown audit type code: " + code);
    }

    /**
     * 根据描述查找枚举值
     *
     * @param description 枚举描述
     * @return 对应的枚举值
     * @throws IllegalArgumentException 如果描述不存在
     */
    public static AuditType fromDescription(String description) {
        for (AuditType type : AuditType.values()) {
            if (type.description.equals(description)) {
                return type;
            }
        }
        throw new IllegalArgumentException("Unknown audit type description: " + description);
    }

    @Override
    public String toString() {
        return description;
    }
}